package com.grass.appointment.adapter;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.TextView;
import com.androidx.p013lv.base.recycler.BaseRecyclerAdapter;
import com.androidx.p013lv.base.recycler.BaseRecyclerHolder;
import com.androidx.p013lv.base.utils.GlideEngine;
import com.androidx.p013lv.base.utils.PictureStyle;
import com.androidx.p013lv.base.utils.TimeUtils;
import com.androidx.p013lv.base.view.NoScrollGridView;
import com.grass.appointment.C2694R;
import com.grass.appointment.bean.WordOfMouth;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.entity.LocalMedia;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class WordOfMouthAdapter extends BaseRecyclerAdapter<WordOfMouth.FeedBackBean, ViewHolder> {
    private Context context;
    private String domain;

    public WordOfMouthAdapter(Context context2) {
        this.context = context2;
    }

    public void setDomain(String str) {
        this.domain = str;
    }

    public void MyHolder(ViewHolder viewHolder, int i) {
        viewHolder.setData((WordOfMouth.FeedBackBean) getDataInPosition(i));
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        return new ViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(C2694R.C2699layout.item_word_of_mouth, viewGroup, false));
    }

    public class ViewHolder extends BaseRecyclerHolder {
        NoScrollGridView grid_view;
        TextView tv_comment;
        TextView tv_nick_name;
        TextView tv_time;

        public ViewHolder(View view) {
            super(view);
            this.tv_nick_name = (TextView) view.findViewById(C2694R.C2697id.tv_nick_name);
            this.tv_time = (TextView) view.findViewById(C2694R.C2697id.tv_time);
            this.tv_comment = (TextView) view.findViewById(C2694R.C2697id.tv_comment);
            this.grid_view = (NoScrollGridView) view.findViewById(C2694R.C2697id.grid_view);
        }

        /* access modifiers changed from: package-private */
        public void setData(final WordOfMouth.FeedBackBean feedBackBean) {
            this.tv_nick_name.setText(feedBackBean.getBackUserName());
            if (TextUtils.isEmpty(feedBackBean.getContent())) {
                this.tv_comment.setVisibility(8);
            } else {
                this.tv_comment.setVisibility(0);
                this.tv_comment.setText(feedBackBean.getContent());
            }
            this.tv_time.setText(TimeUtils.utc2Common(feedBackBean.getRecordAt()));
            DynamicItemAdapter dynamicItemAdapter = new DynamicItemAdapter(WordOfMouthAdapter.this.context, WordOfMouthAdapter.this.domain);
            this.grid_view.setAdapter((ListAdapter) dynamicItemAdapter);
            this.grid_view.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                /* class com.grass.appointment.adapter.WordOfMouthAdapter.ViewHolder.C27711 */

                @Override // android.widget.AdapterView.OnItemClickListener
                public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
                    List<String> feedBackImg = feedBackBean.getFeedBackImg();
                    ArrayList arrayList = new ArrayList();
                    Iterator<String> it = feedBackImg.iterator();
                    while (it.hasNext()) {
                        LocalMedia localMedia = new LocalMedia();
                        localMedia.setPath(WordOfMouthAdapter.this.domain + it.next());
                        arrayList.add(localMedia);
                    }
                    PictureSelector.create((Activity) WordOfMouthAdapter.this.context).setPictureStyle(PictureStyle.getInstance(WordOfMouthAdapter.this.context).getPicturePreviewStyle()).isNotPreviewDownload(false).imageEngine(GlideEngine.createGlideEngine()).openExternalPreview(i, arrayList);
                }
            });
            dynamicItemAdapter.setList(feedBackBean.getFeedBackImg());
        }
    }
}
